﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VipCo.Entities;
using VipCo.Data;

public partial class Controls_TimKiemControl : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindCatalog.BindThanhPho(cboThanhPho);
            HienThiTinTuc();
        }
    }

    /// <summary>
    /// Hiển thị Loại tin
    /// </summary>
    private void HienThiTinTuc()
    {
        int TotalRows = 0;
        TList<TinTuc> TList_TinTuc = DataRepository.TinTucProvider.GetPaged("TrangThai = 1 and IdNhomTin=" + Common.TinTucChinh, "NgayCapNhat DESC", 0, 2, out TotalRows);
        dlTinTuc.DataSource = TList_TinTuc;
        dlTinTuc.DataBind();
    }

    public string GetTieuDe(object Char)
    {
        string s = Char.ToString();
        return Common.ConvertToUnSign(s);
    }

    protected void SelectedindexchangedcboNhomTin(object sender, EventArgs e)
    {
        TList<QuanHuyen> TList_Catalogs = DataRepository.QuanHuyenProvider.Find("IdThanhPho=" + cboThanhPho.SelectedValue);
        cboQuanHuyen.DataSource = TList_Catalogs;
        cboQuanHuyen.DataTextField = "TenQuanHuyen";
        cboQuanHuyen.DataValueField = "Id";
        cboQuanHuyen.DataBind();
    }

    protected void cmdTimKiem_Click(object sender, ImageClickEventArgs e)
    {
        if (cboThanhPho.SelectedValue == "0")
            Response.Redirect("~/TimKiem.aspx?DiaDiem=" + Common.StandardString(txtSearch.Text));
        else
            Response.Redirect("~/TimKiem.aspx?DiaDiem=" + Common.StandardString(txtSearch.Text) + "&IdThanhPho=" + cboThanhPho.SelectedValue + "&IdQuanHuyen=" + cboQuanHuyen.SelectedValue);
    }
}